import 'package:flutter/material.dart';
import "package:get/get.dart";

import '../../../components/appbar_widget/appbar_widget.dart';
import '../../../components/loading/svg_loading.dart';
import '../../../components/status/empty.dart';
import '../../../components/status/not_network.dart';
import '../../../config/global_config.dart';
import '../../../controller/network/network_ctrl.dart';
import '../../../model/bean/lift_info_bean.dart';
import '../../../utils/screenutil/fit.dart';
import 'ctrl/lift_info_ctrl.dart';

class LiftInfo extends StatelessWidget {
  // 导入控制器
  final liftInfoCtrl = Get.put(LiftInfoCtrl());
  final _nc = Get.find<NetworkCtrl>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBarWidget("电梯信息", isMore: true).build(context),
      body: Obx(
        () {
          LiftInfoBean _data = liftInfoCtrl.pageData.value;
          return liftInfoCtrl.isInitComplete.value
              ? Stack(
                  children: [
                    liftInfoCtrl.MARKSYMBOL.value
                        ? Container(
                            margin: EdgeInsets.only(
                              top: _nc.networkStatus.value ? 0 : 60.f,
                            ),
                            child: Container(
                              child: Column(
                                children: [
                                  createContainer(
                                    "所属物业",
                                    content: _data.branchName,
                                  ),
                                  SizedBox(
                                    width: 640.f,
                                    height: 1,
                                    child: Container(
                                      margin: EdgeInsets.only(left: 20.f),
                                      color: GlobalConfig.borderColor,
                                    ),
                                  ),
                                  createContainer(
                                    "小区名称",
                                    content: _data.villageName,
                                  ),
                                  SizedBox(
                                    width: 640.f,
                                    height: 1,
                                    child: Container(
                                      margin: EdgeInsets.only(left: 20.f),
                                      color: GlobalConfig.borderColor,
                                    ),
                                  ),
                                  createContainer(
                                    "安装位置",
                                    content:
                                        "${_data.buildingNo}/${_data.unitNo}/${_data.shaft}",
                                  ),
                                  SizedBox(
                                    width: 640.f,
                                    height: 1,
                                    child: Container(
                                      margin: EdgeInsets.only(left: 20.f),
                                      color: GlobalConfig.borderColor,
                                    ),
                                  ),
                                  createContainer(
                                    "电梯救援识别码",
                                    content: _data.rescueCode,
                                  ),
                                  SizedBox(
                                    width: 640.f,
                                    height: 1,
                                    child: Container(
                                        color: GlobalConfig.borderColor),
                                  ),
                                ],
                              ),
                            ),
                          )
                        : Container(
                            width: 640.f,
                            height: double.infinity,
                            child: Center(child: Empty()),
                          ),

                    // 网络状态
                    Positioned(top: 0, child: NotNetwork()),
                  ],
                )
              : SVGLoading();
        },
      ),
    );
  }

  /// -
  Widget createContainer(String title, {dynamic content = "/"}) {
    return Container(
      padding: EdgeInsets.symmetric(vertical: 20.f, horizontal: 20.f),
      color: Colors.white,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Text(
            "$title",
            style: TextStyle(fontSize: 24.f),
          ),
          Container(
            width: 350.f,
            alignment: Alignment.centerRight,
            child: Text(
              "$content",
              style: TextStyle(fontSize: 24.f),
              textAlign: TextAlign.right,
            ),
          ),
        ],
      ),
    );
  }
}
